package com.fengchao.api.controller.v1;

import com.alibaba.fastjson.JSON;
import com.fengchao.api.config.Constant;
import com.fengchao.api.service.BciService;
import com.fengchao.api.service.CfgService;
import com.fengchao.api.service.UsrService;
import com.fengchao.model.bci.BciArtistInfo;
import com.fengchao.model.bci.BciFieldInfo;
import com.fengchao.model.bci.BciOrganizerInfo;
import com.fengchao.model.cfg.CfgSongType;
import com.fengchao.model.entity.comm.CustomBizException;
import com.fengchao.model.entity.comm.Message;
import com.fengchao.model.entity.comm.ResponseParameter;
import com.fengchao.util.common.CommonValidator;
import com.fengchao.util.common.DateUtil;
import com.fengchao.util.common.UpyunTools;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

import static com.fengchao.api.config.Constant.*;


/**
 * 商业合作方信息模块
 * Created by 王念 on 2016/6/8.
 */
@RestController
@RequestMapping("/v1/bci")
public class BciController {

    @Autowired
    private BciService bciService;
    @Autowired
    private UsrService usrService;
    @Autowired
    private UpyunTools upyunTools;
    @Autowired
    private CfgService cfgService;

    private static Logger logger = LoggerFactory.getLogger(BciController.class);

    @RequestMapping(value = "/getArtistList/{letter}/{page}/{count}", method = RequestMethod.GET)
    @ApiOperation(value = "艺人列表", notes = "必填字段 letter start count ")
    public ResponseParameter getArtistList(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader(required = true) String type,
                                           @ApiParam(value = "用户token") @RequestHeader(required = false) String token,
                                           @ApiParam(value = "根据字母查询(ALL 代表全部）", required = true) @PathVariable("letter") String letter,
                                           @ApiParam(value = "第几页", required = true) @PathVariable("page") Integer page,
                                           @ApiParam(value = "显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("艺人列表请求参数=type:{} token:{} letter:{},page:{},count:{}", type, token, letter, page, count);
        if (!CommonValidator.isStringsNotNull(letter, page, count)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, false);
        List<Map<String, Object>> list = bciService.findArtistByNamePyAndPage(userId, letter, page, count);
        Integer total = bciService.findArtistByNamePyAndPageTotal(letter);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("info", list);
        map.put("total", total);
        responseParameter.setData(map);
        logger.debug("艺人列表响应参数= {}", JSON.toJSON(responseParameter));
        logger.info("艺人列表响应参数= 查询到:{}条,总共:{}条", list.size(), total);
        return responseParameter;
    }


    @RequestMapping(value = "/getArtistH5Info/{artistId}", method = RequestMethod.GET)
    @ApiOperation(value = "获取艺人介绍(WEB)", notes = "必填字段 artistId ")
    public ResponseParameter getArtistH5Info(@ApiParam(value = "艺人id", required = true) @PathVariable("artistId") Integer artistId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取艺人介绍(WEB)请求参数=artistId:{}", artistId);
        String artistInfo = bciService.findArtistInfoByid(artistId);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("artistInfo", artistInfo);
        responseParameter.setData(map);
        logger.info("获取艺人介绍(WEB)响应参数= 是否返回:{}", artistInfo != null);
        logger.debug("获取艺人介绍(WEB)响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/getArtist/{artistId}", method = RequestMethod.GET)
    @ApiOperation(value = "艺人简介", notes = "必填字段 artistId")
    public ResponseParameter getArtist(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader(required = true) String type,
                                       @ApiParam(value = "用户token") @RequestHeader(required = false) String token,
                                       @ApiParam(value = "艺人id", required = true) @PathVariable("artistId") Integer artistId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("艺人简介请求参数=artistId:{}", artistId);
        if (!CommonValidator.isStringsNotNull(artistId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, false);
        Map<String, Object> artistMap = bciService.findArtistById(userId, artistId);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("info", artistMap);
        responseParameter.setData(map);
        logger.debug("艺人简介响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getUserFocusArtist/{page}/{count}", method = RequestMethod.GET)
    @ApiOperation(value = "获取用户关注艺人", notes = "必填字段 artistId")
    public ResponseParameter getUserFocusArtist(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                                @ApiParam(value = "用户token", required = true) @RequestHeader String token,
                                                @ApiParam(value = "第几页", required = true) @PathVariable("page") Integer page,
                                                @ApiParam(value = "显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取用户关注艺人请求参数=type:{},token:{},page:{} artistId:{}", type, token, page, count);
        if (!CommonValidator.isStringsNotNull(type, token, page, count)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        List<Map<String, Object>> list = bciService.findArtistByFocusUserId(userId, page, count);
        HashMap<Object, Object> map = new HashMap<>();
        map.put("info", list);
        responseParameter.setData(map);
        logger.debug("获取用户关注艺人响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/authenticationArtist", method = RequestMethod.POST)
    @ApiOperation(value = "(WEB)认证艺人", notes = "返回参数:</br>成功:</br>{status: SUCCESS, message: 提交成功}" +
            "</br>重新登录:</br>{status: RELOGIN, message: 重新登录}" +
            "</br>失败:</br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 提交失败}")
    public ResponseParameter authenticationArtist(@ApiParam(value = "(必填)类型, WEB", required = true) @RequestHeader String type,
                                                  @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                                  @ApiParam(value = "(必填)姓名", required = true) @RequestParam String name,
                                                  @ApiParam(value = "(必填)手机号码", required = true) @RequestParam String mobile,
                                                  @ApiParam(value = "(必填)国籍", required = true) @RequestParam String nationality,
                                                  @ApiParam(value = "(必填)音乐风格 1;2", required = true) @RequestParam String musicStyle,
                                                  @ApiParam(value = "(必填)性别", required = true) @RequestParam String sex,
                                                  @ApiParam(value = "(必填)邮箱", required = true) @RequestParam String email,
                                                  @ApiParam(value = "艺人简介", required = true) @RequestParam String artistInfo,
                                                  @ApiParam(value = "艺人备注", required = false) @RequestParam(required = false) String artistMemo,
                                                  @ApiParam(value = "(必填)艺人头像", required = true) @RequestParam String headIconPc) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, SUBMIT_FAILURE);
        logger.info("认证艺人请求参数=type:{},token:{},name:{}, mobile:{}, nationality:{},musicStyle:{},sex:{}, email:{}，artistInfo:{},artistMemo:{},headIconPc:{}",
                type, token, name, mobile, nationality, musicStyle, sex, email, artistInfo, artistMemo, CommonValidator.isStringsNotNull(headIconPc));
        if (!CommonValidator.isStringsNotNull(type, token, name, nationality, musicStyle, sex, email)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        String musicStyleJson = null;
        if (CommonValidator.isStringsNotNull(musicStyle)) {
            //将 1;2;3;3 换成json 3;4
            String[] styleIds = musicStyle.split(";");
            List<CfgSongType> list = new ArrayList<>();
            for (String styleId : styleIds) {
                CfgSongType cfgSongType = cfgService.getCfgSongTypeById(Integer.valueOf(styleId));
                if (cfgSongType != null) {
                    list.add(cfgSongType);
                }
            }
            musicStyleJson = JSON.toJSONString(list);
        }
        String headIconPcUrl = headIconPc;
        if (headIconPc.indexOf("data:image/png;base64,") != -1) {//如果上传的不是 url地址 而是base64编码的二进制
            //上传艺人头像
            String fileName = Constant.CONFIGMAP.get("bci.head_icon_pc") + userId + new Date().getTime() + ".png";
            headIconPcUrl = upyunTools.upload(fileName, headIconPc);
        }
        Boolean bool = bciService.authenticationArtist(userId, name, mobile, nationality, musicStyleJson, sex, email, artistInfo, artistMemo, headIconPcUrl);
        if (bool) {
            responseParameter.setMessage(SUBMIT_SUCCESS);
            responseParameter.setStatus(Message.SUCCESS);
        }
        logger.info("认证艺人响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getAuthenticationArtist", method = RequestMethod.GET)
    @ApiOperation(value = "获取认证艺人的信息(WEB)", notes = "必填字段 type,token")
    public ResponseParameter getAuthenticationArtist(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                                     @ApiParam(value = "用户token", required = true) @RequestHeader String token) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取认证艺人的信息=type:{},token:{}", type, token);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        BciArtistInfo bciArtistInfo = bciService.getAuthenticationArtist(userId);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", bciArtistInfo);
        responseParameter.setData(map);
        logger.info("获取认证艺人的信息= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/authenticationOrganizers", method = RequestMethod.POST)
    @ApiOperation(value = "认证主办方(WEB)", notes = "如果是 个人 传  identity  identityFront identtityReverses 如果是公司 传  licenseNumber licenseScanImageUrl")
    public ResponseParameter authenticationOrganizers(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader(required = true) String type,
                                                      @ApiParam(value = "用户token", required = true) @RequestHeader(required = true) String token,
                                                      @ApiParam(value = "主办方名称", required = true) @RequestParam String organizerName,
                                                      @ApiParam(value = "主办方头像", required = true) @RequestParam String organizerHead,
                                                      @ApiParam(value = "主办方的类型 1: 个人  2: 公司", required = true) @RequestParam Integer organizerType,
                                                      @ApiParam(value = "身份证号码") @RequestParam(required = false) String identity,
                                                      @ApiParam(value = "身份证前照") @RequestParam(required = false) String identityFront,
                                                      @ApiParam(value = "身份证后照") @RequestParam(required = false) String identtityReverses,
                                                      @ApiParam(value = "营业执照号码") @RequestParam(required = false) String licenseNumber,
                                                      @ApiParam(value = "营业执照图片") @RequestParam(required = false) String licenseScanImage,
                                                      @ApiParam(value = "联系电话", required = true) @RequestParam String contactMobile,
                                                      @ApiParam(value = "联系邮箱", required = true) @RequestParam String contactEmail,
                                                      @ApiParam(value = "简介", required = true) @RequestParam String companyInfo,
                                                      @ApiParam(value = "备注") @RequestParam(required = false) String memo) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, SUBMIT_FAILURE);
        logger.info("认证主办方请求参数=type:{},token:{},organizerName:{},organizerHead:{}, organizerType:{}, identity:{},licenseNumber:{},identityFront:{}, identtityReverses:{},licenseScanImage:{},authenticationFileUrl:{},contactMobile:{},contactEmail:{},companyInfo,memo",
                type, token, organizerName, CommonValidator.isObjectAttributeNotNull(organizerHead), organizerType, identity, licenseNumber, CommonValidator.isStringsNotNull(identityFront), CommonValidator.isStringsNotNull(identtityReverses), CommonValidator.isStringsNotNull(licenseScanImage), contactMobile, contactEmail, companyInfo, memo);
        if (!CommonValidator.isStringsNotNull(type, token, organizerName, organizerHead, organizerType, contactMobile, contactEmail, companyInfo)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        //判断类型
        String organizerType1 = null;
        String identityFrontUrl = identityFront;
        String identtityReversesUrl = identtityReverses;
        String licenseScanImageUrl = licenseScanImage;
        if (organizerType == 1) {//如果是个人
            if (!CommonValidator.isStringsNotNull(identity, identityFront, identtityReverses)) {
                throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
            }
            organizerType1 = Constant.PERSON;
            //上传身份证正面照文件'
            if (identityFront.indexOf("data:image/png;base64,") != -1) {//如果上传的不是 url地址 而是base64编码的二进制
                String fileName = Constant.CONFIGMAP.get("bci.organizer_identity_front") + userId + new Date().getTime() + ".png";
                identityFrontUrl = upyunTools.upload(fileName, identityFront);
            }
            //上传身份证反面照文件'
            if (identtityReverses.indexOf("data:image/png;base64,") != -1) {//如果上传的不是 url地址 而是base64编码的二进制
                String fileName1 = Constant.CONFIGMAP.get("bci.organizer_identity_reverses") + userId + new Date().getTime() + ".png";
                identtityReversesUrl = upyunTools.upload(fileName1, identtityReverses);
            }
        } else {
            if (!CommonValidator.isStringsNotNull(licenseNumber, licenseScanImage)) {
                throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
            }
            if (licenseScanImage.indexOf("data:image/png;base64,") != -1) {//如果上传的不是 url地址 而是base64编码的二进制
                //上传主办方的营业执照
                String fileName1 = Constant.CONFIGMAP.get("bci.organizer_licenseScan_Image") + userId + new Date().getTime() + ".png";
                licenseScanImageUrl = upyunTools.upload(fileName1, licenseScanImage);
                organizerType1 = Constant.COMPANY;
            }
        }
        //上传认证文件
//        String fileName = Constant.CONFIGMAP.get("bci.organizer_authentication_file") + message.getUserId() + upyunTools.suffix(authenticationFile.getOriginalFilename());
//        String authenticationFileLocation = upyunTools.upload(fileName, authenticationFile.getBytes());
        //上传主办方的头像
        String organizerHeadUrl = organizerHead;
        if (organizerHead.indexOf("data:image/png;base64,") != -1) {//如果上传的不是 url地址 而是base64编码的二进制
            String fileName = Constant.CONFIGMAP.get("bci.organizer_head") + userId + new Date().getTime() + ".png";
            organizerHeadUrl = upyunTools.upload(fileName, organizerHead);
        }
        Boolean bool = bciService.authenticationOrganizer(userId, organizerName, organizerHeadUrl, organizerType1, identity, licenseNumber, identityFrontUrl, identtityReversesUrl, licenseScanImageUrl, null, contactMobile, contactEmail, companyInfo, memo);
        if (bool) {
            responseParameter.setMessage(SUBMIT_SUCCESS);
            responseParameter.setStatus(Message.SUCCESS);
        }
        logger.info("认证主办方响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getAuthenticationOrganizers", method = RequestMethod.GET)
    @ApiOperation(value = "获取认证的主办方的信息(WEB)", notes = "必填字段 type,token")
    public ResponseParameter getAuthenticationOrganizers(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                                         @ApiParam(value = "用户token", required = true) @RequestHeader String token) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取认证的主办方的信息=type:{},token:{}", type, token);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        BciOrganizerInfo bciOrganizerInfo = bciService.getAuthenticationOrganizer(userId);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", bciOrganizerInfo);
        responseParameter.setData(map);
        logger.info("获取认证的主办方的信息= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/authenticationField", method = RequestMethod.POST)
    @ApiOperation(value = "(APP/WEB)认证场地", notes = "返回参数:</br>成功:</br>{status: SUCCESS, message: 提交成功}" +
            "</br>重新登录:</br>{status: RELOGIN, message: 重新登录}" +
            "</br>失败:</br>{status: FAILURE, message: 参数不全}</br>{status: FAILURE, message: 提交失败}")
    public ResponseParameter authenticationField(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                 @ApiParam(value = "(APP/WEB必填)用户token", required = true) @RequestHeader String token,
                                                 @ApiParam(value = "(APP/WEB必填)场地名称", required = true) @RequestParam String fieldName,
                                                 @ApiParam(value = "(APP/WEB必填)场地类型", required = true) @RequestParam String fieldType,
                                                 @ApiParam(value = "(APP/WEB必填)场地地址", required = true) @RequestParam String fieldAddress,
                                                 @ApiParam(value = "(APP/WEB必填)场地头像", required = true) @RequestParam String fieldHead,
                                                 @ApiParam(value = "(APP/WEB必填)联系人", required = true) @RequestParam String contactName,
                                                 @ApiParam(value = "(APP/WEB必填)联系人手机号码", required = true) @RequestParam String contactMobile,
                                                 @ApiParam(value = "(APP/WEB必填)联系邮箱", required = true) @RequestParam String contactEmail,
                                                 @ApiParam(value = "(APP/WEB必填)营业执照号码", required = true) @RequestParam String licenseNumber,
                                                 @ApiParam(value = "(APP/WEB必填)营业执照图片", required = true) @RequestParam String licenseScanImage,
                                                 @ApiParam(value = "(APP/WEB必填)场地图片", required = true) @RequestParam String fieldImage,
                                                 @ApiParam(value = "场地详细") @RequestParam(required = false) String fieldInfo,
                                                 @ApiParam(value = "备注") @RequestParam(required = false) String memo) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, SUBMIT_SUCCESS);
        logger.info("认证场地请求参数= type:{},token:{},fieldName:{},fieldType:{},fieldAddress:{},fieldHead:{},contactName:{},contactMobile:{},contactEmail:{},licenseNumber:{},licenseScanImage:{},fieldInfo:{},memo:{}",
                type, token, fieldName, fieldType, fieldAddress, fieldHead, contactName, contactMobile, contactEmail, licenseNumber, CommonValidator.isStringsNotNull(licenseNumber), fieldInfo, memo);
        Integer userId = usrService.getUserId(type, token, true);
        String fieldHeadUrl = fieldHead;
        String licenseScanImageUrl = licenseScanImage;
        String fieldImageUrl = fieldImage;
        if (fieldHead.indexOf("data:image/png;base64,") != -1) {//如果上传的不是 url地址 而是base64编码的二进制
            //上传头像
            String fileName1 = Constant.CONFIGMAP.get("bci.field_head") + userId + new Date().getTime() + ".png";
            fieldHeadUrl = upyunTools.upload(fileName1, fieldHead);
        }
        if (licenseScanImage.indexOf("data:image/png;base64,") != -1) {//如果上传的不是 url地址 而是base64编码的二进制
            //上传营业执照图片
            String fileName2 = Constant.CONFIGMAP.get("bci.field_company_license_image_url") + userId + new Date().getTime() + ".png";
            licenseScanImageUrl = upyunTools.upload(fileName2, licenseScanImage);
        }
        if (fieldImage.indexOf("data:image/png;base64,") != -1) {//如果上传的不是 url地址 而是base64编码的二进制
            //上传场地图片
            String fileName3 = Constant.CONFIGMAP.get("bci.field_images") + userId + new Date().getTime() + ".png";
            fieldImageUrl = upyunTools.upload(fileName3, fieldImage);
        }
        bciService.authenticationField(userId, fieldName, fieldType, fieldHeadUrl, fieldAddress, contactName, contactMobile, contactEmail, licenseNumber, licenseScanImageUrl, fieldImageUrl, fieldInfo, memo);
        logger.info("认证场地响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/getField", method = RequestMethod.GET)
    @ApiOperation(value = "获取场地的信息", notes = " ")
    public ResponseParameter getField(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                      @ApiParam(value = "用户token", required = true) @RequestHeader String token) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取场地的信息= type:{},token:{}", type, token);
        Integer userId = usrService.getUserId(type, token, true);

        BciFieldInfo bciFieldInfo = bciService.getField(userId);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", bciFieldInfo);
        responseParameter.setData(map);
        logger.info("认证场地响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    @RequestMapping(value = "/editSchedule", method = RequestMethod.POST)
    @ApiOperation(value = "添加或者编辑日程(WEB)", notes = "必填 APP TOKEN")
    public ResponseParameter editSchedule(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                          @ApiParam(value = "用户token", required = true) @RequestHeader String token,
                                          @ApiParam(value = "日程ID") @RequestParam(required = false) Integer scheduleId,
                                          @ApiParam(value = "是否分享 1:分享，0 不分享", required = true) @RequestParam Integer isShared,
                                          @ApiParam(value = "开始时间", required = true) @RequestParam String startTime,
                                          @ApiParam(value = "天数", required = true) @RequestParam Integer days,
                                          @ApiParam(value = "城市", required = true) @RequestParam String city,
                                          @ApiParam(value = "场地名", required = true) @RequestParam String fieldName,
                                          @ApiParam(value = "艺人名", required = true) @RequestParam String artistName,
                                          @ApiParam(value = "简介", required = true) @RequestParam String concertInfo) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, SUBMIT_SUCCESS);
        logger.info("添加或者编辑日程请求参数= type:{},token:{},scheduleId:{},isShared:{},startTime:{},days:{},city:{},fieldName:{},artistName:{},artistName:{},concertInfo:{}",
                type, token, scheduleId, isShared, startTime, days, city, fieldName, artistName, concertInfo);
        if (!CommonValidator.isStringsNotNull(type, token, isShared, startTime, days, city, fieldName, artistName, concertInfo)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        bciService.editSchedule(scheduleId, userId, isShared, DateUtil.parseToDate(startTime, DateUtil.DateFormat_yyyyMMdd), days, city, fieldName, artistName, concertInfo);
        logger.info("添加或者编辑日程响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getMonthTimeSchedule", method = RequestMethod.GET)
    @ApiOperation(value = "获取某个时间段行程日期(WEB)", notes = "必填 APP TOKEN monthTime  monthTime1 artistName fieldName")
    public ResponseParameter getMonthTimeSchedule(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                                  @ApiParam(value = "用户token", required = true) @RequestHeader String token,
                                                  @ApiParam(value = "开始时间 2015-10-1", required = true) @RequestParam String monthTime,
                                                  @ApiParam(value = "结束时间 2015-11-1", required = true) @RequestParam String monthTime1,
                                                  @ApiParam(value = "艺人名字") @RequestParam(required = false) String artistName,
                                                  @ApiParam(value = "场地名称") @RequestParam(required = false) String fieldName) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取某个时间段行程日期 请求参数= type:{},token:{},monthTime:{},monthTime1:{},artistName:{},fieldName:{}",
                type, token, monthTime, monthTime1, artistName, fieldName);
        if (!CommonValidator.isStringsNotNull(type, token, monthTime, monthTime1)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        List<Map<String, Object>> list = bciService.getDateSchedule(monthTime, monthTime1, artistName, fieldName);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", list);
        map.put("total", list.size());
        responseParameter.setData(map);
        logger.info("获取某个时间段行程日期 响应参数= {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getDayTimeSchedule", method = RequestMethod.GET)
    @ApiOperation(value = "获取当天的日程(WEB)", notes = "必填 APP TOKEN daysTime")
    public ResponseParameter getDayTimeSchedule(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                                @ApiParam(value = "用户token", required = true) @RequestHeader String token,
                                                @ApiParam(value = "当前日期 2015-10-5", required = true) @RequestParam String daysTime,
                                                @ApiParam(value = "艺人名字") @RequestParam(required = false) String artistName,
                                                @ApiParam(value = "场地名称") @RequestParam(required = false) String fieldName) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取当天的日程请求参数= type:{},token:{},daysTime:{}", type, token, daysTime);
        if (!CommonValidator.isStringsNotNull(type, token, daysTime)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        List<Map<String, Object>> list = bciService.getDaysSchedule(daysTime, artistName, fieldName);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", list);
        map.put("total", list.size());
        responseParameter.setData(map);
        logger.info("获取当天的日程响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getScheduleById", method = RequestMethod.GET)
    @ApiOperation(value = "根据id获取日程(WEB)", notes = "必填 APP TOKEN scheduleId")
    public ResponseParameter getScheduleById(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                             @ApiParam(value = "用户token", required = true) @RequestHeader String token,
                                             @ApiParam(value = "日程id", required = true) @RequestParam Integer scheduleId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("根据id获取日程请求参数= type:{},token:{},scheduleId:{}", type, token, scheduleId);
        if (!CommonValidator.isStringsNotNull(type, token, scheduleId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Map<String, Object> resultMap = bciService.getScheduleByid(scheduleId);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", resultMap);
        responseParameter.setData(map);
        logger.info("根据id获取日程响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/deleteScheduleById", method = RequestMethod.GET)
    @ApiOperation(value = "删除指定id的日程(WEB)", notes = "必填 APP TOKEN scheduleId")
    public ResponseParameter deleteScheduleById(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                                @ApiParam(value = "用户token", required = true) @RequestHeader String token,
                                                @ApiParam(value = "日程id", required = true) @RequestParam Integer scheduleId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, DELETE_SUCCESS);
        logger.info("删除指定id的日程请求参数= type:{},token:{},scheduleId:{}", type, token, scheduleId);
        if (!CommonValidator.isStringsNotNull(type, token, scheduleId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        bciService.deleteScheduleId(userId, scheduleId);
        logger.info("删除指定id的日程响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getSchedule/{page}/{count}", method = RequestMethod.GET)
    @ApiOperation(value = "获取自己的日程(WEB)", notes = "必填 APP TOKEN")
    public ResponseParameter getSchedule(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                         @ApiParam(value = "用户token", required = true) @RequestHeader String token,
                                         @ApiParam(value = "开始时间  2016-1-1") @RequestParam(required = false) String startTime,
                                         @ApiParam(value = "结束时间 2016-1-31") @RequestParam(required = false) String endTime,
                                         @ApiParam(value = "第几页", required = true) @PathVariable("page") Integer page,
                                         @ApiParam(value = "显示多少条", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取自己的日程请求参数= type:{},token:{},startTime:{},endTime:{},page:{},count:{}", type, token, startTime, endTime, page, count);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        List<Map<String, Object>> list = bciService.getMeSchedule(userId, startTime, endTime, page, count);
        Integer total = bciService.getMeScheduleTotal(userId, startTime, endTime);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", list);
        map.put("total", total);
        responseParameter.setData(map);
        logger.info("获取自己的日程响应参数 = 条数:{} 总条数:{}", list.size(), total);
        logger.debug("获取自己的日程响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getArtistSummaryList/{page}/{count}", method = RequestMethod.GET)
    @ApiOperation(value = "获取心动艺人的列表", notes = "全部必填")
    public ResponseParameter getArtistSummaryList(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                                  @ApiParam(value = "第几页", required = true) @PathVariable("page") Integer page,
                                                  @ApiParam(value = "显示多少条", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取心动艺人的列表请求参数= type:{},page:{},count:{}", type, page, count);
        if (!CommonValidator.isStringsNotNull(type)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        List<Map<String, Object>> list = bciService.getBciArtistSummaryList(page, count);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", list);
        responseParameter.setData(map);
        logger.info("获取心动艺人的列表响应参数 = 条数:{}", list.size());
        logger.debug("获取心动艺人的列表响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    @RequestMapping(value = "/getArtistFocusList/{page}/{count}", method = RequestMethod.GET)
    @ApiOperation(value = "获取艺人的粉丝列表", notes = "全部必填")
    public ResponseParameter getArtistFocusList(@ApiParam(value = "APP或者WEB", required = true) @RequestHeader String type,
                                                @ApiParam(value = "用户token", required = true) @RequestHeader String token,
                                                @ApiParam(value = "第几页", required = true) @PathVariable("page") Integer page,
                                                @ApiParam(value = "显示多少条", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取艺人的粉丝列表请求参数= type:{},page:{},count:{}", type, page, count);
        if (!CommonValidator.isStringsNotNull(type)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Map<Object, Object> map = bciService.getFocusList(userId, page, count);
        responseParameter.setData(map);
        logger.info("获取艺人的粉丝列表响应参数 = 条数:{}", map.get("total"));
        logger.debug("获取艺人的粉丝列表响应参数 = {}", JSON.toJSON(responseParameter));
        return responseParameter;
    }
}